import { initParams, ajaxHeaders } from '@/config';

export const reportSendPage = (event_id: string, data?: Object) => {
    if (window.$SDK_ALL?.sendPage) {
        window.$SDK_ALL.sendPage({
            event_id: event_id, // 唯一事件ID，根据 张超 提供的埋点文档对应传入
            data: {
                referrer: document.referrer,
                href: location.href,
                cookies: document.cookie,
                ...initParams,
                ...ajaxHeaders,
                ...(data || null),
            },
        });
    }
};

export const sendTrack = (event_id: string, data?: Object) => {
    if (window.$SDK_ALL?.sendPageEvent) {
        window.$SDK_ALL.sendPageEvent({
            event_id: event_id, // 唯一事件ID，根据 张超 提供的埋点文档对应传入
            data: {
                referrer: document.referrer,
                ...initParams,
                ...(data || null),
            },
        });
    }
};
